<%@ page language="java" import="com.alibaba.fastjson.JSONObject" pageEncoding="UTF-8" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%--根据物品名称获取总价--%>
<%
    JSONObject jsonData = new JSONObject();
    RecordSet rs = new RecordSet();
    String wpmc = Util.null2String(request.getParameter("wpmc"));
    rs.executeQuery("select mc from uf_bgypkc where id=?",wpmc);
    rs.next();
    String mc = Util.null2String(rs.getString("mc"));
    int bfsl = Util.getIntValue(request.getParameter("bfsl"));
    String wplb = Util.null2String(request.getParameter("wplb"));
    double totalPrice = 0;
    int count = 0;
    int xbfsl = bfsl;
    rs.executeQuery("select id,dj,(sl-isnull(ylysl,0)-isnull(ybfsl,0)) sysl from uf_bgyprkmx " +
            "where wpmc=? and wplb=? and (sfsc is null or sfsc=1) and (sl-isnull(ylysl,0)-isnull(ybfsl,0))>0 " +
            "order by rksj",mc,wplb);
    while (rs.next()) {
        double dj = Util.getDoubleValue(rs.getString("dj"));
        int sysl = Util.getIntValue(rs.getString("sysl"),0);
        //剩余数量
        count = xbfsl - sysl;
        if (count > 0) {
            xbfsl = xbfsl - sysl;
            totalPrice += sysl * dj;
        } else {
            totalPrice += xbfsl * dj;
            break;
        }

    }
    jsonData.put( "zj", totalPrice );
    out.print( jsonData.toJSONString() );
%>






